<template>
	<view class="container">
		<view class="header-box">
			<view class="title">{{schedule.title?schedule.title:''}}</view>
			<view class="text">年份时段：<text class="value">{{schedule.year}}年 {{schedule.period}}</text></view>
			<view class="text">时间日期：<text class="value">{{schedule.startDate?schedule.startDate:''}} - {{schedule.endDate?schedule.endDate:''}}</text></view>
		</view>
		<view class="list">
			<view class="cell-box" v-if="list.length == 0">
				<image class="icon" src="../../static/img/icons/question.png" mode="widthFix"></image>
				<view class="title">无认证安排记录</view>
			</view>
			<view class="cell-box" v-else-if="list[0].checkResult=='审核通过'">
				<image class="icon" src="../../static/img/icons/ok.png" mode="widthFix"></image>
				<view class="title">{{list[0].checkResult}}</view>
			</view>
			<view class="cell-box" v-else-if="list[0].checkResult=='审核不过'">
				<image class="icon" src="../../static/img/icons/close.png" mode="widthFix"></image>
				<view class="title">{{list[0].checkResult}}</view>
			</view>
			<view class="cell-box" v-else>
				<image class="icon" src="../../static/img/icons/wait.png" mode="widthFix"></image>
				<view class="title">{{(!list[0].checkResult || list[0].checkResult == '')?'未审核':list[0].checkResult}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import Store from '@/store/index.js';
	import { ApiIdentifySchedule, ApiIdentifySchedulePerson } from "@/api/identify/index.js";
	import moment from "moment";
	import 'moment/locale/zh-cn';
	
	export default {
		data() {
			return {
				user:{},
				scheduleId: null,
				schedule: {
					title: null
				},
				schedulePerson:{
					id: null
				},
				list: [],
				hasCurrentYear: false
			}
		},
		created() {
			moment.locale('zh-cn');
			this.user = Store.getUser();
		},
		onLoad(option) {
			this.scheduleId = option.scheduleId;
			this.getScheduleInfo();
			
			if(option.id){
				//服务人员操作：
				this.schedulePerson.id = option.id;
				this.getList(option.personId);
			} else {
				//受助人员自己操作：
				this.getList(this.user.id);
			}
		},
		methods: {
			getScheduleInfo(){
				ApiIdentifySchedule.getInfo(this.scheduleId).then(res=>{
					this.schedule = res.data;
				})
			},
			
			getList(personId){
				ApiIdentifySchedulePerson.queryList({
					scheduleId: this.scheduleId,
					personId: personId,
					status: '1'
				}).then(res=>{
					this.list = res.data;
				})
			},
		}
	}
</script>

<style>
	.container {
		width: 750upx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 0;
		margin: 0;
	}
	.header-box{
		width: 690upx;
		display: flex;
		flex-direction: column;
		background-color: white;
		border-radius: 5upx;
		padding: 40upx;
		margin: 30upx;
		box-sizing: border-box;
	}
	.header-box .title {
		font-size: 18px;
		font-weight: bold;
		margin-bottom: 10upx;
	}
	.header-box .text {
		font-size: 14px;
	}
	.header-box .text .value{}
	.list{
		width: 750upx;
		padding: 30upx;
		box-sizing: border-box;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.list .cell-box{
		padding: 40upx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}
	.list .cell-box .icon{
		width: 100upx;
		height: 100upx;
	}
	.list .cell-box .text-wrap{
		margin-left: 30upx;
	}
	.list .cell-box .text-wrap .text{
		margin-bottom: 15upx;
	}
	.list .cell-box .text-wrap .year{
		font-size: 18px;
		font-weight: bold;
	}
	.list .cell-box .title {
		font-size: 18px;
		font-weight: bold;
		margin-top: 20upx;
	}
	.list .cell-box .button {
		padding: 15upx 30upx;
		margin-left: 40upx;
		border-radius: 40upx;
		color: white;
		background: linear-gradient(135deg, #FFA933, #FFE169 );
	}
</style>
